package main

import "fmt"

type Lerson struct {
	name string
	age  int8
}

func NewPerson(name string, age int8) (*Lerson, error) {
	if name == "" {
		return nil, fmt.Errorf("name不能为空")
	}
	if age < 0 {
		return nil, fmt.Errorf("age不能小于0")
	}
	return &Lerson{name: name, age: age}, nil
}

func main() {
	lerson, err := NewPerson("tom", 20)
	if err == nil {
		fmt.Printf("Lerson:%v\n", *lerson)
	} else {
		fmt.Printf("eror:%v\n", err)
	}
}
